Chart inspection results
How many products failed this shift, and why? Rosepetal's chart widgets answer it on the panel as the line runs: bars for OK and NOK, a pie of the results, a line of a value over time and a summary of the shift, which the operator can download as a CSV. In this guide you add them to the panel of a biscuit line.
What you will learn
- How to count results in the flow and draw them as bar, pie and line charts
- How to show a summary of the shift with the reasons for rejecting
- How to let the operator download the counts and start again
Before you start
You need a panel page; here «Biscuit line», with four empty groups: «Packs», «Biscuits per pack», «Shift» and «Trend». Pages and groups are explained in Show inspection results on a panel. The flow streams packs of biscuits through a segmentation model into the function node «Count results», which keeps the counts of the shift in the flow context and sends them in the shape each chart reads, one chart per output (its code is at the end of this page). The group «Shift» already has two buttons, as in Add buttons and selectors to a panel: «Download CSV», wired to the function node «Report», and «Reset», wired to «Count results».
1. Count the results
Double-click «Count results» to see what it does. For each pack, it counts the biscuits the model is sure of, adds the pack to the counts kept in the flow context (flow.set), and sends on each output what one chart reads: the OK and NOK packs for a bar chart, the packs by number of biscuits for a pie chart, the biscuits of this pack for a line chart, and a summary for the shift. A message from «Reset» empties the counts and sends "reset" to every chart.

2. Add a bar chart
Click «Cancel». Type ui-chart-bar in «filter nodes», drag the «chart bar» node, in the «Charts» category, and wire it to the first output. Open it, choose the group «Packs» and write its «Title», «OK and NOK». It draws one bar per key of the payload, { OK: …, NOK: … }, each with its value and colour. «Bar layout» turns the bars on their side.

3. Add a pie chart
Click «Done». Add a «chart pie» node (ui-chart-pie) on the second output, in the group «Biscuits per pack», titled «Biscuits found». It reads labels and values, and optional colors: here green for four biscuits, red for fewer and yellow for more.

4. Add a line chart
Click «Done». Add a «chart line» node (ui-chart-line) on the third output, in the group «Trend», titled «Biscuits per pack». Each number in the payload, here { "Biscuits found": 4 }, is a line, and every message adds a point to it. It keeps the last 100 points. By default it scales each line from its lowest to its highest value, 0 to 100 %, so that lines of different units fit together; in its settings (⚙) the operator turns «Normalize» off to see the real values, chooses which lines to show and how many points to keep.

5. Add a summary of the shift
Click «Done». Add a «session info» node (ui-session-info) on the fourth output, in the group «Shift». It shows the last result, the total and the rejected packs, and a button that opens the reasons, from errorCounter. «No Class Label» names the rejected packs, here «Rejected», and «Param Label» the reasons, here «Reasons».

6. Let the operator download the counts
Click «Done». Add a «csv downloader» node (ui-csv-downloader) after «Report», which answers the «Download CSV» button with the counts of the shift. It belongs to a page, not a group, and shows nothing: choose the page, «Biscuit line», and leave «Field» as payload. Each message makes the browser that has the page open save the object in that field as a CSV: one column per key, one row of values, in a file named after sessionId.

7. Deploy and start the line
Click «Done» and «Deploy», and press the «start» inject node.

8. Open the panel
Open «Panels». Each pack adds to the bars, the pie, the line and the summary of the shift. Point at a bar or a slice to see its value; the icon next to the title of a chart shows it full screen.

9. See why packs were rejected
Click «Reasons» in the summary. The table lists each reason the flow counted in errorCounter with how many packs it rejected: here «Missing biscuits», twice. A reason with no rejected pack yet does not appear.

10. Download the counts
Close the table and press «Download CSV». «Report» sends the counts to the csv downloader, and the browser saves them as session_shift-<date>.csv, ready for a spreadsheet; see «The report» below.
11. Start a new count
Press «Reset». «Count results» forgets the counts and sends "reset" to every chart, which empties it; the next packs start a new count. The counts are kept in the flow context, so a restart of the controller also starts from zero, unless the flow saves them (see Remember values between messages and restarts).

The report
The file the browser saved, session_shift-2026-11-23.csv:
sessionId,packs,ok,nok,missing,extra
"shift-2026-11-23",8,6,2,2,0«Report» builds it from the counts in the flow context:
const c = flow.get("counts") ?? { packs: 0, ok: 0, nok: 0, missing: 0, extra: 0 };
// sessionId names the file: session_<sessionId>.csv
msg.payload = { sessionId: "shift-" + new Date().toISOString().slice(0, 10), packs: c.packs, ok: c.ok, nok: c.nok, missing: c.missing, extra: c.extra };
return msg;The messages for the charts
«Count results» sends what each chart reads on its own output:
// The «Reset» button of the panel starts the count again
if (msg.topic === "reset") {
flow.set("counts", undefined);
return [{ payload: "reset" }, { payload: "reset" }, { payload: "reset" }, { payload: "reset" }];
}
const found = msg.inference.filter((b) => b.confidence >= 0.5).length;
const ok = found === 4;
const c = flow.get("counts") ?? { packs: 0, ok: 0, nok: 0, missing: 0, extra: 0, byCount: {} };
c.packs += 1;
if (ok) c.ok += 1; else c.nok += 1;
if (found < 4) c.missing += 1;
if (found > 4) c.extra += 1;
c.byCount[found] = (c.byCount[found] ?? 0) + 1;
flow.set("counts", c);
const counts = Object.keys(c.byCount).sort();
return [
{ payload: { OK: { value: c.ok, color: "#2e9e43" }, NOK: { value: c.nok, color: "#e53935" } } }, // 1: bar chart
{ payload: { // 2: pie chart
labels: counts.map((n) => n + " biscuits"),
values: counts.map((n) => c.byCount[n]),
colors: counts.map((n) => (n === "4" ? "#2e9e43" : n < "4" ? "#e53935" : "#f9a825")),
} },
{ payload: { "Biscuits found": found } }, // 3: line chart
{ payload: { // 4: shift summary
isAnomalous: !ok, tag: ok ? "OK" : "NOK", totalCounter: c.packs, anomalyCounter: c.nok,
errorCounter: { "Missing biscuits": c.missing, "Extra biscuits": c.extra },
} },
];- Bar chart: one bar per key, with a number or
{ value, color }. - Pie chart:
labels,valuesand, if you want,colors, in the same order. - Line chart: every number in the payload is a line, and each message adds one point to each line. A payload
{ variables: [{ name, values }], labels }replaces the whole chart instead. - Session info:
isAnomalousandtagfor the last result,totalCounter,anomalyCounter, anderrorCounterwith the count of each reason. "reset"empties any of them.
Good to know
- One browser or all. A chart updates every browser that has the panel open. A message that carries
msg._client, such as one that comes from a button, updates only the browser where the button was pressed. - Several rows. The csv downloader writes one row per message. For a table of results, the image history of Keep an image history on a panel or a file written by the flow (Save images and results to disk) are a better fit.
Next steps
Recorded on Rosepetal release 1.8.15, Node-RED 5.0.10.